package capstoneproject.dudiachi.Main;

import java.util.ArrayList;

import capstoneproject.dudiachi.Model.Place;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

public class PlaceGridFragment extends Fragment{
	
	private GridView grid;
	private PlaceGridCellAdapter adapter;
	GridItems[] gridItems = {};
	private Activity activity;
	private ArrayList<Place> list;
	private ArrayList<Bitmap> bitArray;
	
	
	public PlaceGridFragment(GridItems[] gridItems, ArrayList<Place> list, ArrayList<Bitmap> bitArray, Activity activity) {
		this.gridItems = gridItems;
		this.activity = activity;
		this.list = list;
		this.bitArray = bitArray;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view;
		
		view = inflater.inflate(R.layout.activity_grid, container, false);
		
		grid = (GridView) view.findViewById(R.id.grid);
		adapter = new PlaceGridCellAdapter(activity.getApplicationContext(), list, bitArray, gridItems);
		adapter.notifyDataSetChanged();
		grid.setAdapter(adapter);
		return view;
	}
}
